SUMMARY = "IPP-over-USB daemon for Linux"
HOMEPAGE = "https://github.com/OpenPrinting/ipp-usb"
LICENSE = "Apache-2.0 & MIT"
LIC_FILES_CHKSUM = "file://LICENSE;md5=35b61b5975388824d233d3f4ee283ad0"
PV = "0.9.30"
SRC_URI = "git://github.com/OpenPrinting/ipp-usb.git;protocol=https;nobranch=1;branch=${PV};"
SRCREV = "42c0eb90b183f0c744961caaee2b64b0a733fca2"

S = "${WORKDIR}/git"

DEPENDS = "avahi libusb1"
inherit go pkgconfig 

do_compile() {
    cd ${S}
    export GOARCH="${TARGET_GOARCH}"
    export GOOS="${TARGET_GOOS}"
    export CGO_ENABLED="1"
    export CC="${TARGET_PREFIX}gcc"
    export CXX="${TARGET_PREFIX}g++"
    export CGO_CFLAGS="${CFLAGS} --sysroot=${STAGING_DIR_TARGET}"
    export CGO_LDFLAGS="${LDFLAGS} --sysroot=${STAGING_DIR_TARGET}"
    oe_runmake
}

do_install() {
    cd ${S}
    install -d ${D}${bindir}
    install -m 0755 ${S}/ipp-usb ${D}${bindir}/
    install -d ${D}${libdir}/udev/rules.d
    install -m 0755 ${S}/systemd-udev/*.rules ${D}${libdir}/udev/rules.d/
    install -d ${D}${libdir}/systemd/system
    install -m 0755 ${S}/systemd-udev/*.service ${D}${libdir}/systemd/system/
    install -d ${D}/${sysconfdir}/ipp-usb
    install -m 0755 ${S}/ipp-usb.conf ${D}/${sysconfdir}/ipp-usb/   
    install -d ${D}${mandir}/man8
    gzip -9 -c ${S}/ipp-usb.8 > ${D}${mandir}/man8/ipp-usb.8.gz
    chmod 0755 ${D}${mandir}/man8/ipp-usb.8.gz
    install -d ${D}${datadir}/ipp-usb/quirks
    install -m 0755 ${S}/ipp-usb-quirks/* ${D}${datadir}/ipp-usb/quirks/
}

FILES:${PN} += " \
    ${bindir}/ipp-usb \
    ${libdir}/udev/rules.d/* \
    ${libdir}/systemd/system/*.service \
    ${sysconfdir}/ipp-usb/* \
    ${mandir}/man8/* \
    ${datadir}/ipp-usb/quirks/* \
"

INSANE_SKIP:${PN} += "already-stripped"
INSANE_SKIP:${PN} += "buildpaths"

